<?php
  // reset avatars state and position if he get stuck on map, this will warp him back to hurnscald
  require_once dirname(__FILE__)."/../purin2/core/core.php";
  require_once dirname(__FILE__)."/../purin2/user/session.php";
  require_once dirname(__FILE__)."/../purin2/xtr/xtr.php";
  
  // get input parameters
  $j_user = $pu_user_serial;
  if ($j_user <= 0)
    die('You must be logged in to reset your position');

  // where to reset?
  $j_tmap = puSelect("select i_tmap from tmap where v_name='Hurnscald'");
  $i_x = 1520;
  $i_y = 1120;
  $v_action = 'stand';
  $v_animation = 'down';
  /*
  for now we only reset map and position
  $j_head = puInt('j_head');
  $j_hair = puInt('j_hair');
  $i_red = puInt('i_red');
  $i_green = puInt('i_green');
  $i_blue = puInt('i_blue');
  $j_chest = puInt('j_chest');
  $j_leg = puInt('j_leg');
  $j_feet = puInt('j_feet');
  $j_hands = puInt('j_hands');
  $v_race = puStr('v_race','male',array('male','female'));
  */
  
  // update
  $sql = "update asta set i_x=$i_x, i_y=$i_y, j_tmap=$j_tmap, v_action='$v_action', v_animation='$v_animation', d_update=NOW() where j_user=$j_user";
  $rows = puUpdate($sql,true);
  if ($rows < 0)
    die("Update failed: ".mysql_error());

  header('Location: ../index.php');
?>